package com.example.springbootusecase.bo;

/**
 * @author Think
 */
public class UserContextHolder {
    private static ThreadLocal<User> userHolder = new ThreadLocal<>();

    public static void setUser(User user) {
        userHolder.set(user);
    }

    public static User getUser() {
        return userHolder.get();
    }

    public static void clear() {
        userHolder.remove(); // 避免内存泄漏
    }
}

